#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <set>
using namespace std;
class Solution
{
public:
    double findMaxAverage(vector<int> &nums, int k)
    {
        int i = 0, j = 0;
        double tmp = 0, ans = 0;
        while (j - i < k)
            tmp += nums[j++];
        tmp /= k, ans = tmp;
        while (j < nums.size())
        {
            tmp -= 1.0 * nums[i++] / k;
            tmp += 1.0 * nums[j++] / k;
            ans = max(ans, tmp);
        }
        return ans;
    }
};